<p class="Paragraph">FileNumber: Number of the file from which data is to be read. The file must have been opened by the Open statement with the key word INPUT.</p>
<p class="Paragraph">var: A variable to which the values read from the file are assigned. Numeric and string variables are valid.</p>
<p class="Paragraph">The <span class="T1">Input#</span> statement is used to read numeric values or strings from an open file and assign the data to one or more variables. A numeric variable is read up to the first carriage return (Asc=13), line feed (Asc=10), space, or comma. String variables are read to the first carriage return (Asc=13), line feed (Asc=10), or comma.</p>
<p class="Paragraph">Data and data types in a file must appear in the same order as the variables passed in var. If you assign non-numeric values to a numeric variable, the variable is assigned the value zero.</p>
<p class="Paragraph">Since records in the file may be separated by commas, commas cannot be read to a string variable. Quotation marks (") in the file are disregarded as well. If you want to read these characters from the file, use the <span class="T1">Line Input#</span> statement to read pure text files (files containing only printable characters) line by line.</p>
<p class="Paragraph">If the end of the file is reached while reading a data element, an error occurs and the process is aborted.</p>
<p class="P2">Example:</p>
<p class="PropText">Sub ExampleWorkWithAFile</p>
<p class="PropText">Dim iNumber As Integer</p>
<p class="PropText">Dim sZeile As String</p>
<p class="PropText">Dim aFile As String</p>
<p class="PropText">Dim sMsg as String</p>
<p class="PropText">aFile = "c:\data.txt"</p>
<p class="PropText"/>
<p class="PropText">iNumber = Freefile</p>
<p class="PropText">Open aFile For Output As #iNumber</p>
<p class="PropText">Print #iNumber, "This is a line of text"</p>
<p class="PropText">Print #iNumber, "This is another line of text"</p>
<p class="PropText">Close #iNumber</p>
<p class="PropText"/>
<p class="PropText">iNumber = Freefile</p>
<p class="PropText">Open aFile For Input As iNumber</p>